<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/static/include/taglib.jsp"%>
<!DOCTYPE html >
<html>
<head>
 <meta name="viewport" content="width=device-width" />
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>后台管理--模板编辑</title>
 <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet" />
 <link href="${ctxStatic}/css/kpiuitanchu.css" rel="stylesheet" />
 <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
 <script src="${ctxStatic}/layui/layui.all.js"  type="text/javascript"></script>
</head>
<body>
<div class="tanchucontent" style="width:90%">
 <form class="layui-form" id="formedit" name="formedit" action="add_attroutine" method="post" target="d41d8cd98f00b204e9800998ecf8427e">
    <iframe name="d41d8cd98f00b204e9800998ecf8427e" src="about:blank" style="display:none;"></iframe>

    <table nostyle="true">
     <tr>
      <td class="td_right" style="min-width:60px;width:60px">年份：</td>
      <td>
        <select id="year" name="year">
            <option value="2025">2025年</option>
            <option value="2024">2024年</option>
            <option value="2023">2023年</option>
            <option value="2022">2022年</option>
            <option value="2021">2021年</option>
            <option value="2020">2020年</option>
            <option value="2019">2019年</option>
            <option value="2018">2018年</option>
            <option value="2017">2017年</option>
	       </select>
      </td>
      <td class="td_right" style="min-width:60px;width:60px">月份：</td>
      <td>
         <select id="mouth" name="mouth">
	       <option value="1">1月</option>
	       <option value="2">2月</option>
	       <option value="3">3月</option>
	       <option value="4">4月</option>
	       <option value="5">5月</option>
	       <option value="6">6月</option>
	       <option value="7">7月</option>
	       <option value="8">8月</option>
	       <option value="9">9月</option>
	       <option value="10">10月</option>
	       <option value="11">11月</option>
	       <option value="12">12月</option>
	       </select>
      </td>
     </tr>
     <tr>
      <td class="td_right" style="min-width:60px;width:60px">周：</td>
      <td>
        <select id="week" name="week">
	            <option value="1">第一周</option>
	           <option value="2">第二周</option>
	           <option value="3">第三周</option>
	           <option value="4">第四周</option>
	         </select>
      </td>
      <td class="td_right" style="min-width:60px;width:60px"></td>
      <td></td>
     </tr>
     <tr>
      <td class="td_right" style="min-width:60px;width:60px">工作内容：</td>
      <td colspan="3">
        <textarea class="layui-textarea"  name="routinedes" >${entity.routinedes }</textarea>
      </td>
     </tr>
     <tr>
       <td colspan="4" style="text-align: center">
         <button class="button" lay-submit="" lay-filter="demo1" id="btnsave">保存</button>
		 <input type="button" value="关闭" class="button" onclick="top.CloseOpenWindow()"/>
       </td>
     </tr>

    </table>




     <input type="hidden" id="hidyear" value="${year }"/>
     <input type="hidden" name="routineid" id="routineid" value="${routineid }">
      <input type="hidden" name="routinetype" value="1">

 </form>

   <input type="hidden" id="hidmonth" value="${entity.mouth }">
   <input type="hidden" id="hidweek" value="${entity.week }">

 <script>
 layui.use('form', function(){
	   var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
       $("#year").val($("#hidyear").val());
	   if($("#routineid").val()>0){
		   $("#mouth").val($("#hidmonth").val());
		   $("#week").val($("#hidweek").val());
	   }else {

	        var date=new Date();
           $("#mouth").val(new Date().getMonth()+1);
           $("#week").val(getMonthWeek(date.getFullYear(),date.getMonth()+1,date.getDate()));
       }
	   form.render('select');

     form.render();
 });
  function  getMonthWeek(a, b, c) {
     //a = d = 当前日期
     //b = 6 - w = 当前周的还有几天过完(不算今天)
     //a + b 的和在除以7 就是当天是当前月份的第几周
     var date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate();
     return Math.ceil((d + 6 - w) / 7);
 };

   function CloseDialog(result,msg){
    	  top.frames["iframe"].vAttRoutine.addresult(result,msg);
      }
 </script>
</div>
</body>
</html>